package com.deft.design.factory.calc;

import com.deft.design.factory.ICalculator;
import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;

/**
 * @author zdl
 * @description 除法计算
 * @date 2022-04-18
 **/
@Slf4j
public class DivideCalc implements ICalculator {
    @Override
    public BigDecimal execCalc(BigDecimal first, BigDecimal second) {
        if (second.equals(BigDecimal.ZERO)) {
            log.error("除数不能为0");
            return null;
        }
        return first.divide(second, 2, BigDecimal.ROUND_UP);
    }
}
